package com.lxr0860.lxr0860production_test.base;

import android.annotation.SuppressLint;
import android.app.Application;
import android.os.PowerManager;

import android.content.Context;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;

import com.lxr0860.lxr0860production_test.db.MyRoomDatabase;


/**
 * 类描述:[全局类]
 * 说明:
 *
 * @author: LXR-zsm
 * @Date: 2023/10/17 9:38
 */
public class App extends Application {
    private static Context context;
    private static boolean netState = false;

    @Override
    public void onCreate() {
        super.onCreate();
        context = this;
        // 注册全局异常处理类
//        CrashExceptionHandler crashExceptionHandler = CrashExceptionHandler.newInstance();
//        crashExceptionHandler.init(getApplicationContext());
        //数据库初始化
        MyRoomDatabase.getInstance();
        //音频初始化
    //       MySoundUtils.getInstance();
        setWakeLock(true);


    }

    private void setWakeLock(boolean state) {
        PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
        @SuppressLint("InvalidWakeLockTag") PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "myWakeLockTag");
        if (state) {
            wakeLock.acquire();
        } else {
            wakeLock.release();
        }
    }

    public static Context getContext() {
        return context;
    }


    public static void setNetState(boolean b) {
        netState = b;
    }

    public static boolean getNetState() {
        return netState;
    }
}
